package com.zhijian.medical.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.zhijian.response.annotation.Response;
import com.zhijian.util.page.Page;

import com.zhijian.medical.entity.po.CnasNew;
import com.zhijian.medical.service.CnasNewService;
import com.zhijian.medical.entity.vo.request.CnasNewSearchVo;
import com.zhijian.medical.entity.vo.request.CnasNewSaveOrUpdateVo;
import com.zhijian.medical.entity.vo.response.CnasNewVo;

import lombok.extern.slf4j.Slf4j;
import java.util.List;

/**
 * cnas相关内容 控制层
 * 
 * @author auto
 * @version 1.0
 * @date 2025-06-17 10:45:42
 */
@Slf4j
@Controller
@Api(tags = "cnas管理")
public class CnasNewController {

	@Autowired
    private CnasNewService service;

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/cnas/new/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody CnasNewSaveOrUpdateVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.modify(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/cnas/new/{id}")
    @ApiOperation("根据id查询")
    public CnasNewVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    @Response
    @GetMapping("/cnas/new/{id}/{sopType}")
    @ApiOperation("根据id和type查询")
    public CnasNewSaveOrUpdateVo.ReviewContent selectContent(@PathVariable("id") Long id, @PathVariable("sopType") Byte sopType) {
        log.info("{} - {}| query selectContent info", this.getClass().getSimpleName(), id);
        return service.selectContent(id, sopType);
    }

    /**
     * 根据id查询
     *
     * @param type
     * @return
     */
    @Response
    @GetMapping("/cnas/new/type/{type}")
    @ApiOperation("根据type查询")
    public CnasNewVo selectByType(@PathVariable("type") Integer type) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), type);
        // 此处type唯一
        return service.selectOne(CnasNewSearchVo.builder().type(type).build());
    }


    /**
        * 列表查询
        *
        * @param param
        * @return
    */
    @Response
    @PostMapping("/cnas/new/list")
    @ApiOperation("列表查询")
    public List<CnasNewVo> selectList(@RequestBody(required = false) CnasNewSearchVo param) {
            if (param == null)
                param = CnasNewSearchVo.builder().build();
            log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
            return service.selectList(param);
        }


}